﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LineChartControlTest
{
    /// <summary>
    /// PolynomialFit.xaml 的交互逻辑
    /// </summary>
    public partial class PolynomialFit : Window
    {
        public PolynomialFit()
        {
            InitializeComponent();
            AddData();
        }

        private void AddData()
        {
            double[] x = new double[] { 1, 2, 3, 4, 5 };
            double[] y = new double[] { 5.5, 43.1, 128, 290.7, 498.4 };

            LineCharts.FittingCurve ds = new LineCharts.FittingCurve();
            ds.LineColor = Brushes.Blue;
            ds.XDrawStart = 0;
            ds.XDrawEnd = 6;
            ds.FitM = 1;
            ds.FittingMode = LineCharts.FittingCurve.FittingModeEnum.PolynomialFit;
            ds.LineThickness = 2;
            ds.SeriesName = "Polynomial m1 and Original";
            ds.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.Diamond;
            ds.Symbols.SymbolSize = 15;
            ds.Symbols.FillColor = Brushes.Black;
            ds.Symbols.BorderColor = Brushes.Black;
            for (int i = 0; i < x.Length; i++)
            {
                ds.RawData.Add(x[i], y[i]);
            }
            myLineChart.SeriesCollection.AddRawData(ds);

            LineCharts.FittingCurve ds1 = new LineCharts.FittingCurve();
            ds1.LineColor = Brushes.Red;
            ds1.LinePattern = LineCharts.LinePatternEnum.Dash;
            ds1.XDrawStart = 0;
            ds1.XDrawEnd = 6;
            ds1.FitM = 2;
            ds1.FittingMode = LineCharts.FittingCurve.FittingModeEnum.PolynomialFit;
            ds1.LineThickness = 2;
            ds1.SeriesName = "Polynomial m2 and Original";
            ds1.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.None;
            ds1.Symbols.SymbolSize = 15;
            ds1.Symbols.FillColor = Brushes.Black;
            ds1.Symbols.BorderColor = Brushes.Black;
            for (int i = 0; i < x.Length; i++)
            {
                ds1.RawData.Add(x[i], y[i]);
            }
            myLineChart.SeriesCollection.AddRawData(ds1);

            LineCharts.FittingCurve ds2 = new LineCharts.FittingCurve();
            ds2.LineColor = Brushes.Purple;
            ds2.LinePattern = LineCharts.LinePatternEnum.Dot;
            ds2.XDrawStart = 0;
            ds2.XDrawEnd = 6;
            ds2.FitM = 3;
            ds2.FittingMode = LineCharts.FittingCurve.FittingModeEnum.PolynomialFit;
            ds2.LineThickness = 2;
            ds2.SeriesName = "Polynomial m3 and Original";
            ds2.Symbols.SymbolType = LineCharts.Symbols.SymbolTypeEnum.None;
            ds2.Symbols.SymbolSize = 15;
            ds2.Symbols.FillColor = Brushes.Black;
            ds2.Symbols.BorderColor = Brushes.Black;
            for (int i = 0; i < x.Length; i++)
            {
                ds2.RawData.Add(x[i], y[i]);
            }
            myLineChart.SeriesCollection.AddRawData(ds2);
        }
    }
}
